package com.augurit.gzcgwsp.readAndParseXML.errorContext;

public class MyErrorContext {
	public static class MyError {
		int errno;
		String szErrorDesc;

		public MyError(int errno, String errorDesc) {
			this.errno = errno;
			this.szErrorDesc = errorDesc;
		}

		public int getErrorNo() {
			return errno;
		}

		public String getErrorDesc() {
			return szErrorDesc;
		}
	}

	public static final int PARSE_XML_FAIL= 1000; // 解析XML失败
	public static final int INSERTINTO_DB_FAIL = 1001; // 插入数据库失败
	
	private static final MyError[] errormap = {
			new MyError(PARSE_XML_FAIL, "解析XML失败"),
			new MyError(INSERTINTO_DB_FAIL, " 插入数据库失败")
			, };

	public static String getErrorInfo(int errno) {
		for (int i = 0; i < errormap.length; i++) {
			if (errno == errormap[i].getErrorNo()) {
				return errormap[i].getErrorDesc();
			}
		}
		return "";
	}

	public String getErrorMessage(int errorcode) {
		String error = null;
		for (int i = 0; i < errormap.length; i++) {
			if (errormap[i].getErrorNo() == errorcode) {
				error = errormap[i].getErrorNo() + "："
						+ errormap[i].getErrorDesc();
				break;
			}
		}
		return error;
	}
}
